package com.idudiao.sc.common.log;

import com.idudiao.sc.common.log.event.MQLogListener;
import com.idudiao.sc.common.log.aspect.OperationLogAspect;
import com.idudiao.sc.common.log.event.OperationLogListener;
import com.idudiao.sc.common.log.feign.BasicFeign;
import lombok.AllArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;

/**
 * 日志自动配置
 *
 * @author songyinyin
 * @date 2019/1/9 16:24
 */
@EnableAsync
@Configuration
@AllArgsConstructor
@ConditionalOnWebApplication
public class LogAutoConfiguration {

    private final BasicFeign basicFeign;

    @Bean
    public OperationLogAspect operationLogAspect() {
        return new OperationLogAspect();
    }

    @Bean
    public OperationLogListener operationLogListener() {
        return new OperationLogListener(basicFeign);
    }

    @Bean
    public MQLogListener mqLogListener() {
        return new MQLogListener(basicFeign);
    }
}
